<script setup>
import {ref} from "vue"
import Nav_bottom from "../../components/navigation/bottom/nav_bottom.vue";
import {getHomeUserInfo} from "../../api/user/user";
import {baseUrl} from "../../api/http";
import {goHouseholdManagement, goMyFamily, goPropertdetails, goRecycleOrderList, goWastedetail,goManage} from "../../tools/go";
import {clear, setFamily, setHouseHold} from "../../store";

const userInfo = ref({
  nick:'',
  avatar:'',
  phone:'',
  email:'',
  address:'',
  sex:'',
  birthday:''
})

const list2 = [
  {id:1,name:'消息',img:'./static/img/mineimg/xiaoxi.png'},
  {id:2,name:'我的订单',img:'./static/img/mineimg/wddd.png', go:goRecycleOrderList},
  {id:3,name:'我的小区',img:'./static/img/mineimg/wdxq.png'},
  {id:4,name:'我的社区',img:'./static/img/mineimg/wdsq.png'},
]

const list3 = [
  {id:1,name:'设置',img:'./static/img/mineimg/shezhi.png'},
  {id:2,name:'关怀',img:'./static/img/mineimg/gy.png'},
  {id:3,name:'管理',img:'./static/img/mineimg/fx.png',go:goManage},
  {id:4,name:'退出登录',img:'./static/img/mineimg/guanyu.png',go: () => {
      uni.showModal({
        title: '提示',
        content: '确定要退出登录吗？',
        success: (res) => {
          if (res.confirm) {
            clear()
            uni.reLaunch({
              url: '/pages/index/index'
            })
          }
        }
      })
    }},
]
const list = ref([
  {
    id:1,
    name:'家庭',
    img:'./static/img/mine/jt.png',
    go: goMyFamily
  },
  {
    id:2,
    name:'房屋',
    img:'./static/img/mine/fw.png',
    go: goHouseholdManagement
  },
  {
    id:3,
    name:'车辆',
    img:'./static/img/mine/cl.png',
  },
])

const getInfo = () => {
  getHomeUserInfo().then(res => {
    userInfo.value = res.data

    setFamily(res.data.familyId)
    setHouseHold(res.data.householdId)

  })
}

const init = () => {
  getInfo()

}

init()



</script>

<template class="body">
  <view class="me">
    <view class="back">
      <view class="header">
        <view class="user">
          <img :src="baseUrl + userInfo.img" alt="">
          <view>
            <p>{{userInfo.nick}}</p>
            <span>{{ userInfo.phone }}</span>
          </view>
        </view>
        <ul class="nav">
          <li v-for="item in list" :key="item.id" @click="item.go">
            <img :src="item.img" alt="">
            <span>{{ item.name }}</span>
          </li>
        </ul>
      </view>
      <view class="win">
        <view class="list2">
          <ul>
            <li v-for="item in list2" :key="item.id" @click="item.go">
              <view>
                <img :src="item.img" alt="">
                <text>{{ item.name }}</text>
              </view>
              <v-icon class="icon" icon="mdi-chevron-right"></v-icon>
            </li>
          </ul>
        </view>
        <view class="list3">
          <ul>
            <li v-for="item in list3" :key="item.id" @click="item.go">
              <view>
                <img :src="item.img" alt="">
                <text>{{ item.name }}</text>
              </view>
              <v-icon class="icon" icon="mdi-chevron-right"></v-icon>
            </li>
          </ul>
        </view>
      </view>

    </view>
  </view>
<!--  <view class="kong" style="height: 100px;background: #CACACA"></view>-->
  <nav_bottom who-active="我的"></nav_bottom>
</template>

<style scoped lang="scss">
@use "../../static/css/main";

/* 全局样式重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'PingFang SC', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.me {
  width: 100%;
  min-height: 100vh;
  padding-bottom: 80px; /* 为底部导航预留空间 */
  
  .back {
    @include main.useTheme() {
      /* 头部区域样式 */
      .header {
        width: 100%;
        height: auto;
        min-height: 30vh;
        background: main.getVal("pri_color");
        border-radius: 0 0 24px 24px;
        padding-bottom: 20px;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
        position: relative;
        overflow: hidden;
        
        /* 用户信息样式 */
        .user {
          display: flex;
          align-items: center;
          padding: 24px 16px;
          color: white;
          position: relative;
          
          &::after {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(255, 255, 255, 0.05);
            pointer-events: none;
          }
          
          img {
            width: 70px;
            height: 70px;
            border-radius: 50%;
            object-fit: cover;
            border: 2px solid white;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
            transition: transform 0.3s ease;
            
            &:hover {
              transform: scale(1.05);
            }
          }
          
          view {
            margin-left: 16px;
            display: flex;
            flex-direction: column;
            
            p {
              font-size: 20px;
              font-weight: 500;
              margin-bottom: 4px;
              letter-spacing: 0.5px;
            }
            
            span {
              font-size: 14px;
              opacity: 0.9;
            }
          }
        }
        
        /* 导航菜单样式 */
        .nav {
          width: 92%;
          margin: 0 auto;
          background: main.getVal("primary_bg_color");
          border-radius: 12px;
          display: flex;
          box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
          overflow: hidden;
          
          li {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            flex: 1;
            padding: 16px 0;
            position: relative;
            transition: all 0.2s ease;
            
            &:not(:last-child)::after {
              content: '';
              position: absolute;
              right: 0;
              top: 20%;
              height: 60%;
              width: 1px;
              background: main.getVal("primary_border_color");
            }
            
            &:hover {
              background: main.getVal("two_lv_bg_color");
            }
            
            img {
              width: 40px;
              height: 40px;
              margin-bottom: 8px;
              transition: transform 0.2s ease;
            }
            
            span {
              font-size: 14px;
              color: main.getVal("primary_text_color");
            }
            
            &:active img {
              transform: scale(0.95);
            }
          }
        }
      }
      
      /* 功能列表区域 */
      .win {
        padding: 10px 12px;
        margin-top: -10px;
        
        /* 通用列表样式 */
        .list2, .list3 {
          background: main.getVal("primary_bg_color");
          border-radius: 12px;
          overflow: hidden;
          box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
          margin-bottom: 16px;
          
          ul {
            display: flex;
            flex-direction: column;
            
            li {
              display: flex;
              align-items: center;
              justify-content: space-between;
              padding: 14px 16px;
              border-bottom: 1px solid main.getVal("primary_border_color");
              transition: background-color 0.2s ease;
              
              &:last-child {
                border-bottom: none;
              }
              
              &:hover {
                background-color: main.getVal("two_lv_bg_color");
              }
              
              &:active {
                background-color: main.getVal("two_lv_bg_color");
              }
              
              view {
                display: flex;
                align-items: center;
                
                img {
                  width: 24px;
                  height: 24px;
                  object-fit: contain;
                }
                
                text {
                  margin-left: 12px;
                  font-size: 15px;
                  color: main.getVal("primary_text_color");
                }
              }
              
              .icon {
                color: main.getVal("one_lv_text_color");
                transition: transform 0.2s ease;
              }
              
              &:hover .icon {
                transform: translateX(3px);
                color: main.getVal("pri_color");
              }
            }
          }
        }
        
        /* 第二列表特殊样式 */
        .list2 {
          margin-top: 20px;
          
          li {
            view img {
              width: 24px;
              height: 24px;
            }
          }
        }
        
        /* 第三列表特殊样式 */
        .list3 {
          margin-top: 20px;
          
          li {
            view img {
              width: 24px;
              height: 24px;
            }
          }
        }
      }
    }
  }
}

/* 滚动条样式 */
body::-webkit-scrollbar {
  display: none;
}

</style>